package jdbc_practice;

import jdbc.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class Demo3 {
    public static void main(String[] args) {
        try (Connection connection = DBUtil.getConnection();){
            String  sql  = "UPDATE user " +
                    "SET password = ?,nickname = ?,age = ? " +
                    "WHERE id = ?";
            PreparedStatement ps = connection.prepareStatement(sql);
            ps.setString(1,"666666");
            ps.setString(2,"老三");
            ps.setInt(3,33);
            ps.setInt(4,1);
            ResultSet rs = ps.executeQuery();
            if(rs.next()){
                System.out.println("修好成功");
            }else {
                System.out.println("修改失败");
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
